from django.db import models


# Create your models here.

class CarTable(models.Model):
    name = models.CharField(max_length=20, unique=True, verbose_name='车名')
    money = models.DecimalField(max_digits=9, decimal_places=2, verbose_name='价钱')
    color = models.CharField(max_length=10, verbose_name='颜色')
    types = models.CharField(max_length=10, verbose_name='车型')
    stutus = models.BooleanField(verbose_name='状态')
    content = models.TextField(verbose_name='介绍', default='')
    pic = models.ImageField(verbose_name='图片', default='')

    class Meta:
        db_table = 'CAR'


class Suser(models.Model):
    name = models.CharField(max_length=20, verbose_name='姓名')
    username = models.CharField(max_length=225, verbose_name='用户名')
    password = models.CharField(max_length=255, verbose_name='密码')

    class Meta:
        db_table = 'suser'


class Shop(models.Model):
    name = models.CharField(max_length=20, verbose_name='名称')
    price = models.DecimalField(max_digits=7, decimal_places=2, verbose_name='价格')
    stock = models.IntegerField(default=999, verbose_name='库存')
    pic = models.ImageField(verbose_name='图片')
    comments = models.IntegerField(default=0, verbose_name='评论数')

    class Meta:
        db_table = 'shop'
        verbose_name = '商品表'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.name


class Comtent(models.Model):
    user = models.ForeignKey(Suser, on_delete=models.CASCADE)
    shop = models.ForeignKey(Shop, on_delete=models.CASCADE,related_name='con')
    content = models.TextField()

    class Meta:
        db_table = 'comtent'
